package pe.edu.unmsm.fisi.sisconteg.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.unmsm.fisi.sisconteg.business.service.TesisService;
import pe.edu.unmsm.fisi.sisconteg.domain.model.Egresado;
import pe.edu.unmsm.fisi.sisconteg.domain.model.Tesis;
import pe.edu.unmsm.fisi.sisconteg.repository.dao.TesisDAO;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class TesisServiceImpl implements TesisService {

	@Resource
	private TesisDAO tesisDAO;
	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void crearTesis(Tesis tesis, Egresado egresado)
			throws DataAccessException {
		tesis.setEgresado(egresado);
		tesisDAO.crearTesis(tesis);
	}

	@Override
	public List<Tesis> getTesisxTema(String temaTesis)
			throws DataAccessException {
		return tesisDAO.getTesisxTema(temaTesis);
	}

	@Override
	public List<Tesis> getTesisxFlag(Integer tipoTesisTesina)
			throws DataAccessException {
		boolean flag = (tipoTesisTesina==0)? false : true;
		return tesisDAO.getTesisxFlag(flag);
	}

	@Override
	public List<Tesis> getTesisxGrado(Integer gradoTesis)
			throws DataAccessException {
		return tesisDAO.getTesisxGrado(gradoTesis);
	}

}
